﻿using System;
using System.Collections.Generic;
using System.Text;
using Torch.WL.Business.Interface;
using Torch.FrameWork.Utility;
using Torch.WL.Business.CleanChina;
using Torch.WL.Entity.CleanChina;

namespace Torch.WL.Business
{
    public class RewardProvider : BaseProvider<RewardProvider.RequestDataInfo>, IDataProvider
    {
        public RewardProvider(string _jsonInfo)
            : base(_jsonInfo)
        {

        }

        public IMessageInfo Do()
        {
            message.data = ProcessResponseData();
            return message;
        }

        private List<ResponseDataInfo> ProcessResponseData()
        {
            if (postdata == null || postdata.data == null)
            {
                message.code = (int)MessageCodeType.WrongRequestPara;
                message.message = Utils.GetEnumDescription(MessageCodeType.WrongRequestPara);
                return null;
            }

            //use postdata.data to process responseData
            List<ResponseDataInfo> list = new List<ResponseDataInfo>();


            List<TbCompanyEntity> listCompany = TbCompanyManager.Instance().GetRewardCompanyByCache(postdata.data.rewardid);

            listCompany.ForEach(delegate(TbCompanyEntity entity) {
                    list.Add(new ResponseDataInfo() { companyid = entity.companyId, companyname = entity.companyName, logo = entity.companyLogo });
                });

            #region 虚代码
            /*
            ResponseDataInfo responseData = new ResponseDataInfo();
            responseData.companyid = 100;
            responseData.companyname = "上海清洁用品制造有限公司";
            responseData.logo = ConfigHelper.GetConfigString("WebsiteImageUrl") + "loading_1.jpg";
            list.Add(responseData);

            responseData = new ResponseDataInfo();
            responseData.companyid = 101;
            responseData.companyname = "北京清洁用品制造有限公司";
            responseData.logo = ConfigHelper.GetConfigString("WebsiteImageUrl") + "loading_1.jpg";
            list.Add(responseData);

            responseData = new ResponseDataInfo();

            responseData.companyid = 102;
            responseData.companyname = "广州清洁用品制造有限公司";
            responseData.logo = ConfigHelper.GetConfigString("WebsiteImageUrl") + "loading_1.jpg";
            list.Add(responseData);
            */
            #endregion

            return list;

         
        }

        public class RequestDataInfo
        {
            public int rewardid { get; set; }
        }

        public class ResponseDataInfo
        {
            public int companyid { get; set; }
            public string companyname { get; set; }
            public string logo { get; set; }

        }


    }
}
